# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=atscan
pkgver=2461.06521a9
pkgrel=3
groups=('blackarch' 'blackarch-scanner' 'blackarch-webapp' 'blackarch-fuzzer'
        'blackarch-exploitation' 'blackarch-automation')
pkgdesc='Server, Site and Dork Scanner.'
arch=('any')
url='https://github.com/AlisamTechnology/ATSCAN-V3.1'
license=('MIT')
depends=('perl' 'perl-io-socket' 'perl-uri' 'perl-term-ansicolor'
         'perl-html-parser' 'perl-term-readkey' 'perl-http-cookies'
         'perl-getopt-long' 'perl-http-message' 'perl-encode-locale'
         'perl-file-copy-recursive' 'perl-libwww')
makedepends=('git' 'dos2unix')
source=("$pkgname::git+https://github.com/AlisamTechnology/ATSCAN-V3.1.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  dos2unix "$pkgname.pl"

  sed -i 's|defined @ARGV|@ARGV|' "$pkgname.pl"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec perl $pkgname.pl "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

